package com.xkdx.guangguang.fragment.shopunitproduct;

import org.json.JSONArray;
import org.json.JSONObject;

import com.xkdx.guangguang.module.network.AbsModule;
import com.xkdx.guangguang.shareclass.ProductInfo;

public class UnitProductModule extends AbsModule {

	public String message;
	public ProductInfo info;

	@Override
	public void parseData() throws Exception {
		backJson = (JSONArray) result;
		try {
			for (int i = 0; i < backJson.length(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("getProductDetail")) {
					info = parserPayGoods(jsonObj.getJSONObject("DetailInfo"));
				}

			}
		} catch (Exception e) {
			throw e;
		}

	}

	private ProductInfo parserPayGoods(JSONObject person) throws Exception {
		ProductInfo info = new ProductInfo();
		try {
			if (person == null) {
				return null;
			}

			if (!(person.isNull("DetailInfo"))) {
				JSONObject stut = (JSONObject) person.get("DetailInfo");
				info.setProductID(stut.getString("ID"));
				info.setLogo(stut.getString("Logo"));
				info.setProductName(stut.getString("Product_Name"));
				info.setPicturePath(stut.getString("PicturePath"));
				info.setProduct_Detail(stut.getString("Product_Detail"));
				info.setProductPrice(stut.getString("Product_Price"));
				info.setExChange_Num(stut.getString("ExChange_Num"));
				info.setRemain_Num(stut.getString("Remain_Num"));
			}

			return info;
		} catch (Exception e) {
			throw e;
		}

	}
}
